﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PraxisRent.Entities;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace PraxisRent.Repository.Mapping
{
    public class CLIENTE_NATURALMap:EntityTypeConfiguration<CLIENTE_NATURAL>
    {
        public CLIENTE_NATURALMap()
        {
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            //Primary Key
            this.HasKey(t => t.ClienteNaturalId);

            //Properties
            this.Property(t => t.ClienteNaturalId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Dni)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.Nombre)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ApPaterno)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ApMaterno)
                .IsRequired()
                .HasMaxLength(50);

            this.ToTable("CLIENTE_NATURAL");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ClienteNaturalId).HasColumnName("ClienteNaturalId");
            this.Property(t => t.Dni).HasColumnName("Dni");
            this.Property(t => t.Nombre).HasColumnName("Nombre");
            this.Property(t => t.ApPaterno).HasColumnName("ApPaterno");
            this.Property(t => t.ApMaterno).HasColumnName("ApMaterno");

            this.HasRequired(t => t.CLIENTE)
                .WithOptional(t => t.CLIENTE_NATURAL)
                .WillCascadeOnDelete(false);
        }
    }
}
